package com.jlee.android.pimclient.activity;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;

import com.jlee.android.pimclient.PIMClientConstant;
import com.jlee.android.pimclient.R;

/**
 * This Activity is intended to be the main activity of the
 * application. Since we don't have a UI specification now, 
 * just use simple list items.
 */
public class PIMClientMainActivity extends ListActivity {
	// Define the list items
	private static final String[] LIST_ITEMS = {
		"Device Status",
		"Setting"
	};
	private static final int ITEM_DEVICESTATUS_INDEX = 0;
	private static final int ITEM_SETTING_INDEX = 1;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setTitle(R.string.title_main);
		
		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, LIST_ITEMS));
		getListView().setTextFilterEnabled(false);
        getListView().setOnItemClickListener(new AdapterView.OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				switch (position) {
				case ITEM_DEVICESTATUS_INDEX:
					startActivity(PIMClientStatusActivity.class);
					break;
				case ITEM_SETTING_INDEX:
					startActivity(PIMClientMainSettingActivity.class);
					break;
				default:
					Log.e(PIMClientConstant.TAG, "Unknown position: " + position);
				}
			}

        });
    }
	
	void startActivity(Class<?> cls) {
		startActivity(new Intent(this, cls));
	}
}
